Repository navigation
hx-upsert: only sort inserted elements when sort is set - #4228
Open
cestercian wants to merge 1 commit into
Open
cestercian wants to merge 1 commit into
cestercian wants to merge 1 commit into
Conversation
New keyed elements were placed in sorted order even when the sort modifier was omitted. Append them, or prepend them when that modifier is set, unless sort or sort:desc is requested.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
hx-upsertwas inserting new keyed elements in sorted order even whensortwas not set. The modifier was already parsed (hx-swap="upsert sort"/sort:desc, and thesortattribute on<hx-upsert>), buthandle_swapnever checkedswapSpec.sort.Without
sort, new elements are appended. Withprependand nosort, they go at the start, in the order they appear in the response.sortandsort:descstill sort the same way as before.Before, a target with
item-1,item-3and a response of newitem-2plus updateditem-3(hx-swap="upsert") came out1, 2, 3. It now stays1, 3, 2.Corresponding issue: Fixes #4226
Testing
Added tests in
test/tests/ext/hx-upsert.js:sortappends new keyed elements, and an updated element stays where it wasprependwithoutsortinserts new keyed elements at the start, in response ordersortandsort:descstill sort<hx-partial hx-swap="upsert">and the<hx-upsert>tagnpm run testpassed (1854 passed, 0 failed, 4 skipped). Also ranpython3 src/scripts/content/check.py. There is no lint script inpackage.json. Leftdist/alone.Checklist
masterfor website changes,devforsource changes)
approved via an issue
npm run test) and verified that it succeeded